<?php

use Elite\Infrastructure\Server\Swoole;
use Swoole\Coroutine;

define('ROOT_DIR', dirname(dirname(__FILE__)));

Coroutine::set(['hook_flags'=> SWOOLE_HOOK_ALL]);

require ROOT_DIR . '/vendor/autoload.php';

/** @var Swoole */
$swoole = new Swoole(Swoole::SWOOLE_SERVER_HTTP, ROOT_DIR . '/.env');

$swoole->loadServerConfig([
    'user' => 'www-data',
    'group' => 'www-data',
    'heartbeat_check_interval' => 3600, // 1小时
    'max_wait_time' => 30,
    'package_max_length' => 50 * 1024 * 1024, // 50M
    'reload_async' => true,
    'log_file' => '/var/log/elite/swoole.log',
    'log_date_with_microseconds' => SWOOLE_LOG_ROTATION_DAILY
]);
$swoole->loadEventListener(ROOT_DIR . '/listener');
$swoole->startServer();